<%@ Control Language="C#" %>
<%@ Register TagPrefix="CSD" Namespace="CommunityServer.Discussions.Controls" Assembly="CommunityServer.Discussions" %>
<%@ Register TagPrefix="CS" Namespace="CommunityServer.Controls" Assembly="CommunityServer.Controls" %>
<%@ Import Namespace="CommunityServer.Discussions.Controls" %>
<%@ Import Namespace="CommunityServer.Discussions.Components" %>
<%@ Import Namespace="CommunityServer.Components" %>
<%@ Import Namespace="CommunityServer.Controls" %>
<%@ Import Namespace="CommunityServer" %>

<script language="C#" runat="server">
	bool IsAnswer(PostStatus status)
	{
		return ((status & PostStatus.IsAnswer) == PostStatus.IsAnswer);
	}
</script>

<script type="text/javascript" language="javascript">

function markAsAnswer(postid, mark)
{
	var button = $('button-' + postid);

	if (button.isAnswer == null)
		button.isAnswer = !mark;
	else
		button.isAnswer = !button.isAnswer;

	PostFlatViewAJAX.TogglePostStatus('<%= this.Parent.ClientID %>',postid,null);

	if (button.isAnswer)
		button.innerHTML = '<%= ResourceManager.GetString("MarkAsAnswer") %>';
	else
		button.innerHTML = '<%= ResourceManager.GetString("MarkAsNotAnswer") %>';
}

</script>

<CSD:InlineTagEditor runat="server" id="InlineTagEditor" LinkCssClass="CommonTextButton" CssClass="CommonInlineTagEditor" />

<div class="CommonContentArea">
	<div class="CommonBreadCrumbArea"><CSD:BreadCrumb ShowHome="true" runat="server" id="Breadcrumb3"/></div>
	<CS:AdPart runat = "Server" contentname="StandardTop" ID="Adpart1">
	    <CS:Ads Zone="StandardTop" runat="server" id="Ads1" />
	</CS:AdPart>
	<h2 class="CommonTitle"><asp:Label ID="ForumName" Runat="server" /></h2>
	<div class="CommonContent">
		<div class="CommonDescription"><asp:Label CssClass="h2Desc" id="ThreadStats" Runat="server" /></div>
		
		<div class="CommonFormArea">
		<table cellpadding="0" cellspacing="0" border="0" width="100%">
			<tr>
				<td colspan="2" align="right" class="CommonFormField CommonPrintHidden">
					<asp:PlaceHolder runat="server" id="PagingArea2">
						<div class="CommonPagingArea" align="right">
							<CS:CurrentPage id="CurrentPage2" runat="server" Cssclass="columnText"></CS:CurrentPage>
							&nbsp;
							<CSD:ForumPager id="Pager2" runat="server"></CSD:ForumPager>
						</div>
					</asp:PlaceHolder>
				</td>
			</tr>
			<tr>
				<td align="left" class="CommonFormField CommonPrintHidden">
					<CSD:RatePost id="RateThread" runat="server" visible="false" CssClass="ForumThreadRateControl" ReadOnlyCssClass="ForumThreadRateControlReadOnly" ActiveCssClass="ForumThreadRateControlActive" ImagesBaseUrl="~/Themes/default/images/common/" />
					<CS:ThreadSubscribeLinkButton runat="server" id="TrackingButton" UseImages="true" TrackingResourceName="PostFlatView_EnableThreadTrackingOn" NotTrackingResourceName="PostFlatView_EnableThreadTrackingOff" />
					<csd:ChangeViewPopupMenu runat="server" id="ChangeViewPopupMenu" activebuttoncssclass="CommonImageTextButtonHighlight" inactivebuttoncssclass="CommonImageTextButton" innerbuttoncssclass="CommonButtonInnerContentDown" />
				</td>
				<td align="right" class="CommonFormField CommonPrintHidden">
					<CS:ResourceLabel runat="server" ResourceName="PostView_SortPostsLabel" id="Resourcelabel1"/>
					<CS:PostsSortDropDownList runat="server" id="SortOrder" AutoPostBack="True" />
					<CSD:ForumImageButton ButtonType="PreviousTopic" id="PrevThread" runat="server" />
					<CSD:ForumImageButton ButtonType="NextTopic" id="NextThread" runat="server" />
				</td>
			</tr>
		</table>
		</div>
		<asp:Repeater id="PostRepeater" Runat="server">
			<HeaderTemplate>
				<ul class="ForumPostList">
			</HeaderTemplate>
			<ItemTemplate>
				<li>
				<div class="ForumPostArea">
					<h4 class="ForumPostHeader">
						<table cellpadding="0" cellspacing="0" border="0" width="100%">
							<tr valign="middle">
								<td align="left"><a runat="server" id="PostAnchor"><CS:ThemedImage runat="server" border="0" ImageUrl="/images/icon_post_show.gif" id="Themedimage1" /></a>&nbsp;<%# Formatter.FormatAgoDate (((ForumPost) Container.DataItem).PostDate) %></td>
								<td align="right" class="ForumPostHeaderControlArea">
									<CS:Href id="PostLink" runat="server" /><CS:ResourceControl runat="server" ResourceName="PostView_ReplyToLabel" id="ReplyToLabel" visible="False" /><CS:Href id="ParentLink" runat="server" />
									<CSD:RatePost id="RatePost" runat="server" visible="false"  CssClass="CommonRateControl" ReadOnlyCssClass="CommonRateControlReadOnly" ActiveCssClass="CommonRateControlActive" ImagesBaseUrl="~/Themes/default/images/common/" />	
								</td>
							</tr>
						</table>
					</h4>
					<table cellspacing="0" cellpadding="0" border="0" width="100%" style="table-layout: auto;">
						<tr valign=top>
							<td rowspan="2" class="ForumPostUserArea">
								<div class="ForumPostUserContent">
								<ul class="ForumPostUserPropertyList">
									<li class="ForumPostUserName">
										<CS:UserOnlineStatus runat="server" id="OnlineStatus" />
										<asp:Literal runat="server" id="Username" />
									</li>
									<li class="ForumPostUserAvatar CommonPrintHidden">
										<CS:UserAvatar runat="server" Border="1" PadImage="False" id="Avatar" />
									</li>
									<li class="ForumPostUserIcons CommonPrintHidden">
										<CS:PostIcons runat="server" id="PostIcon" />
									</li>
									<li class="ForumPostUserAttribute">
										<CS:UserAttribute FormatString="{0}" Attribute="Joined" runat="server" id="JoinedAttribute" />
									</li>
									<li class="ForumPostUserAttribute">
										<CS:UserAttribute FormatString="{0}" Attribute="Location" runat="server" id="LocationAttribute" />
									</li>
									<li class="ForumPostUserAttribute">
										<CS:UserAttribute FormatString="{0}" Attribute="Posts" runat="server" id="PostsAttribute" />
									</li>
									<li class="ForumPostUserAttribute">
										<CS:UserAttribute FormatString="{0}" Attribute="Points" runat="server" id="PointsAttribute" />
									</li>
									<li class="ForumPostRoleIcons CommonPrintHidden">
										<CS:RoleIcons runat="server" id="RoleIcon" EnablePadding="false"/>
									</li>
								</ul>
								</div>
							</td>
							<td class="ForumPostContentArea">
								<div class="ForumPostTitleArea">
									<h4 class="ForumPostTitle">
										<asp:Literal runat="server" id="Emoticon" />
										<asp:Literal runat="server" id="Subject" />
									</h4>
									
									<div class="ForumPostAttachment">
										<CSD:PostAttachment runat="server" id="PostAttachment" />
									</div>

									<div class="ForumPostThreadStatus">
										<CS:ResourceControl runat="server" ResourceName="PostView_ThreadStatusLabel" id="ThreadStatusLabel"/> <CSD:StatusDropDownList runat="server" id="ThreadStatus" />
										<asp:Panel ID="AnswerPanel" Runat="server">
											<a id="button-<%# DataBinder.Eval(Container.DataItem, "PostID") %>" class="CommonTextButton" href="javascript:markAsAnswer(<%# DataBinder.Eval(Container.DataItem, "PostID") %>, <%# (!IsAnswer((PostStatus)DataBinder.Eval(Container.DataItem, "PostStatus"))).ToString().ToLower() %>)"><%# IsAnswer((PostStatus)DataBinder.Eval(Container.DataItem, "PostStatus")) ? ResourceManager.GetString("MarkAsNotAnswer") : ResourceManager.GetString("MarkAsAnswer") %></a>
										</asp:Panel>
									</div>

									<div class="ForumPostButtons">
										<CSD:ForumImageButton runat="server" ButtonType="Reply" id="ReplyButton" />
										<CSD:ForumImageButton runat="server" ButtonType="Quote" id="QuoteButton" />
										<CSD:ForumImageButton runat="server" ButtonType="Delete" id="DeleteButton" />
										<CSD:ForumImageButton runat="server" ButtonType="Edit" id="EditButton" />
										<cs:favoritepopupmenu id="FavoritePopupMenu" runat="server" activebuttoncssclass="CommonImageTextButtonHighlight" inactivebuttoncssclass="CommonImageTextButton" innerbuttoncssclass="CommonButtonInnerContentDown" />
										<cs:contactpopupmenu id="ContactPopupMenu" runat="server" activebuttoncssclass="CommonImageTextButtonHighlight" inactivebuttoncssclass="CommonImageTextButton" innerbuttoncssclass="CommonButtonInnerContentDown" />
										<csd:moderationpopupmenu id="ModerationPopupMenu" runat="server" activebuttoncssclass="CommonTextButtonHighlight" inactivebuttoncssclass="CommonTextButton" innerbuttoncssclass="CommonButtonInnerContentDown" />
									</div>
								</div>

								<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%" style="table-layout: fixed;">
								<tr><td>
									<div class="ForumPostBodyArea">
									<div class="ForumPostContentText" id = "PostViewWrapper" runat="server">
										<CSD:PostView runat="server" id="PostView" />
									</div>
									</div>
								</td></tr>
								</table>
							</td>
						</tr>
						<tr valign="bottom">
							<td class="ForumPostFooterArea">
								<div>
									<CS:InlineTagEditorPanel runat="server" id="InlineTagEditorPanel" InlineEditorID="InlineTagEditor" />
								</div>								
								<ul class="ForumPostStatistics CommonPrintHidden" style="clear: both;">
									<CS:ListItemLiteral runat = "Server" id = "PostPoints" />
									<CS:ListItemLiteral runat = "Server" id = "PostIPAddress" />
									<CS:ListItemLink runat = "Server" id = "ReportLink" />
									<CS:ListItemLink runat = "Server" id = "quickReplyLink" />
								</ul>
							</td>
						</tr>
					</table>
				</div>
				</li>
			</ItemTemplate>
			<FooterTemplate>
				</ul>
			</FooterTemplate>
		</asp:Repeater>

		<asp:PlaceHolder runat="server" id="PagingArea">
			<div class="CommonPagingArea" align="right">
				<CS:CurrentPage id="CurrentPage" runat="server" Cssclass="columnText"></CS:CurrentPage>
				&nbsp;
				<CSD:ForumPager id="Pager" runat="server"></CSD:ForumPager>
			</div>
		</asp:PlaceHolder>

		<table cellpadding="0" cellspacing="0" width="100%" border="0">
			<tr>
				<td colspan="2" align="right">
					<div class="CommonWebFeedArea CommonPrintHidden">
						<csd:postrsslink runat="server" id="Postrsslink1" name="Postrsslink1"/>
					</div>
				</td>
			</tr>
		</table>
	</div>		
	<CS:AdPart runat = "Server" contentname="StandardBottom" ID="Adpart2">
	    <CS:Ads Zone="StandardBottom" runat="server" id="Ads3" />
	</CS:AdPart>

</div>
